﻿using ChiWalker.Dynamics;
using ChiWalker.Helpers;
using ChiWalker.Spell;
using ChiWalker.Utilities;
using Styx;
using Styx.TreeSharp;

namespace ChiWalker.Routines.Hunter
{
    internal class Beast_Master
    {
        [Behavior(BehaviorType.Combat | BehaviorType.Pull)]
        [Spec(WoWSpec.HunterBeastMastery)]
        [Class(WoWClass.Hunter)]
        public static Composite BeastMaster()
        {
            return new PrioritySelector(
                Safers.EnsureTarget(),
                WaitFor.WaitForCast(),
                Movement.FaceMyTarget(),
                Movement.MoveToLoS(ret => StyxWoW.Me.CurrentTarget),
                Pet.CreatPetBehavoir(),
                new CastOnMyTarget(Spell.MultiShot,
                    ret =>
                        Clusters.GetClusterCount(StyxWoW.Me.CurrentTarget, Clusters.NearbyUnitsInCombatWithMe,
                            ClusterType.Radius, 8f) > 3),
                new CastOnMyTarget(Spell.HuntersMark, ret => !StyxWoW.Me.CurrentTarget.HasAura("Hunter's Mark")),
                new CastOnMyTarget(Spell.KillCommand, ret => StyxWoW.Me.GotAlivePet),
                new CastOnMyTarget(Spell.KillShot),
                new CastOnMyTarget(Spell.SerpentSting, ret => !StyxWoW.Me.CurrentTarget.HasMyAura("Serpent Sting")),
                new CastOnSelf(Spell.Fervor, ret => StyxWoW.Me.CurrentFocus <= 50),
                new CastOnMyTarget(Spell.GlaiveToss),
                new CastOnMyTarget(Spell.DireBeast),
                new CastOnMyTarget(Spell.FocusFire,
                    ret =>
                        StyxWoW.Me.HasAura("Frenzy") && StyxWoW.Me.GetAuraStackCount("Frenzy", true) == 5),
                new CastOnMyTarget(Spell.ArcaneShot),
                new CastOnMyTarget(Spell.ChimeraShot),
                new CastOnMyTarget(Spell.SteadyShot),
                Movement.MoveToUnit(ret => StyxWoW.Me.CurrentTarget, ret => 40f)
                );
        }
    }
}